package com.company.cloud.club.modules.db.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.ArrayList;
import java.util.List;

/**
 * *****************************************************************************
 * <p>
 * 功能名           ：com.company.cloud.club.app.db.domain
 * 系统名           ：
 * <p>
 * *****************************************************************************
 * Modification History
 * <p>
 * Date        Name                    Reason for Change
 * ----------  ----------------------  -----------------------------------------
 * 2020/7/28     zhangxu                 Created
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("club_comment")
public class Comment extends BaseEntity {

    /**
     * 评论话题
     */
    private String topic;

    /**
     * 标签
     */
    private String label;

    /**
     * 点赞数量
     */
    @TableField("praise_num")
    private Integer praiseNum;

    /**
     * 回复文本
     */
    private String text;

    /**
     * 图/音/视资源
     */
    @TableField("resource_ids")
    private String resourceIds;

    /**
     * 会员Id
     */
    @TableField("user_id")
    private Integer userId;

    /**
     * 话题父级ID
     */
    @TableField("parent_id")
    private String parentId;

    @TableField("img_url")
    private String imgUrl;

    /**
     * 评论关联的帖子ID
     */
    @TableField("root_id")
    private String rootId;

    /**
     * 用户是否点赞
     */
    @TableField(exist = false)
    private Integer isMemberPraise;

    @TableField(exist = false)
    private Integer commentNum;

    @TableField(exist = false)
    private String voiceUrl;

    @TableField(exist = false)
    private String nickname;

    @TableField(exist = false)
    private String avatarUrl;

    @TableField(exist = false)
    private List<Comment> comments = new ArrayList<>();

    public void addComment(Comment comment) {
        if (comment != null) {
            this.comments.add(comment);
        }
    }

    public void addAllComment(List<Comment> list) {
        this.comments.addAll(list);
    }
}